# 作者:何恺
# 2025年02月18日15时51分27秒
# 2557170485@qq.com

xiaoming = {
    "name": "小明",
    "age": 18,
    "gender": "male"
}
print(xiaoming["name"])
xiaoming["home"] = "66"  # 如果key不存在，会增加键值对
# len() 统计多少键值对
xiaoming2 = {
    "name": "小明",
    "age": 18,
    "gender": "male"
}
print(id(xiaoming2))
print(id(xiaoming))  # id不一样

list1 = [1, 2, 3, 4, 5]
list2 = [1, 2, 3, 4, 5]
print(id(list2))
print(id(list1))  # id不一样
# 遍历
for k,v in xiaoming.items():
    print(k, v)
for k in xiaoming.values():
    print(k)


# 字典是无序的，因此无法用下标访问
xiaoli = [{"name":"xiaoli1"
          ,"age":181,},
          {"name":"xiaoli2"
          ,"age":182,}]
for i in xiaoli:
    print(i)

# 合并字典 .update()
# 存在不增，不存在新增 .setdefault(,)
# 删除 del 字典[]
# 删除 .pop()
# 查找 .get() 不存在不会报异常
